<template>
	<view class="contain1">
		<view class="" style="display: flex;justify-content: center;">
			<image style="width: 250rpx;border-radius: 50%; margin-top: 50rpx;"  src="../../static/uni.png" mode="widthFix"></image>
		</view>
		<view class="show" style="">
			<uni-forms :modelValue="formData">
				<uni-forms-item label="账号" name="name">
					<uni-easyinput type="text" v-model="formData.username" placeholder="请输入账号" />
				</uni-forms-item>
				<uni-forms-item label="密码" name="password">
					<uni-easyinput type="password" v-model="formData.password" placeholder="请输入密码" />
				</uni-forms-item>
			</uni-forms>
			<view @click="region" class="" style="text-align: right;">注册>></view>
			<button @click="login" style="background-color: aqua;">登录</button>
		</view>
	</view>
</template>

<script>
	import * as request from '@/unitl.js'
	export default {
		data() {
			return {
				formData:{
					username:'rx',
					password:'123456'
				}
				
			}
		},
		methods: {
			async login(){
				const res=await request.default.login(this.formData)
					uni.setStorage({
						key:"token",
						data:res.data.token,
						success:()=> {
							this.$showtost.showTost(res.data.code,res.data.msg)
							setTimeout(()=>{
								uni.switchTab({
									url:'/pages/index/index'
								})
							},1500)
						},
						fail() {
							console.log(111)
							this.$showtost.showTost(res.data.code,res.data.msg)
						}
					})
					
				
			},
			region(){
				uni.navigateTo({
					url:"/pages/region/region"
				})
			}
			
		}
	}
</script>

<style>
	.contain1{
		background-image: url('../../static/login/top.png');
		background-repeat: no-repeat;
		background-size: 100%;
	}
	.show{
		margin: 10px auto;
		width: 80%;
		border-radius: 20rpx;
		padding: 20rpx;
		background-color: aliceblue;
		box-shadow: 1px 1px 2px 2px rgba(0, 0, 0, .1);
	}

</style>
